home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1985 September
/
Ahoy_Magazine_85-09_1985_Double_L.d64
/
dice analyzer
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
1KB
|
49 lines
0 rem << rr21-2 >>
1 print"[147]":poke53280,0:poke53281,6:poke646,1
2 print"-- dice analyzer --"
3 rem rupert report #21
4 rem
5 print"enumerate all possible"
6 print"outcomes for rolling three dice"
7 rem
8 print">>calculate the probability that"
10 print" 1) 3 ones are rolled"
11 print" 2) at least 1 three and 1 six are rolled"
12 print" 3) no twos are rolled"
13 print" 4) the sum is eleven"
14 print" press any key";:input a$
15 rem >on the nth roll (n = 1 to 216):
16 rem roll(n,y) = die y's value
17 rem ct(n,z) = # dice with value z
18 rem ttl(n) = sum of dice values
19 rem
20 dim roll(216,3),ct(216,6),ttl(216),rnum(216)
30 n=1 : m=1 : print chr$(147)
40 for a=1 to 6 : for b=1 to 6
50 for c=1 to 6
60 print a;b;c
70 roll(n,1)=a:roll(n,2)=b:roll(n,3)=c
80 ct(n,a)=ct(n,a)+1 :ct(n,b)=ct(n,b)+1
90 ct(n,c)=ct(n,c)+1
100 ttl(n)=a+b+c
110 n=n+1 : next c : next b : next a
120 print"calculating ... "
130 for n=1 to 216
140 :if ct(n,1)=3 then t1=t1+1
150 :if ct(n,3)>=1 and ct(n,6)>=1 then t2=t2+1
160 :if ct(n,2)=0 then t3=t3+1
170 :if ttl(n)=11 then t4=t4+1:rnum(m)=n:m=m+1
180 next n
190 print
200 print,"# success"," % probability"
210 print "test 1",t1,t1*100/216
220 print "test 2",t2,t2*100/216
230 print "test 3",t3,t3*100/216
240 print "test 4",t4,t4*100/216
250 print
260 print"successful rolls for test 4:"
270 for m=1 to t4
280 rm=rnum(m)
290 print roll(rm,1);roll(rm,2);roll(rm,3),
300 next m